import request from './http';
import { queryParamsType } from '@/utils/model';

export function getContactInfo() {
  return request({
    url: '/contact',
    method: 'get',
  });
}

export function getMetas() {
  return request({
    url: '/meta',
    method: 'get',
  });
}
// 获取基本信息
export async function getBasicInfo() {
  const [metaResponse, contactResponse] = await Promise.all([getMetas(), getContactInfo()]);
  return { metaInfo: metaResponse.data, contactInfo: contactResponse.data };
}
// 服务端获取列表数据
export async function getArticles(params?: queryParamsType) {
  const result = await request({
    url: '/articles/search',
    method: 'get',
    params: {
      keyword: params?.keyword,
      pageSize: 20,
    },
  });
  return result.data;
}
// 客户端获取数据
export async function getArticlesInWeb(params?: queryParamsType) {
  const result = await request({
    url: 'api/articles/search',
    method: 'get',
    params: {
      ...params,
      pageSize: params?.pageSize || 20,
    },
  });
  return result.data;
}
